package cn.iocoder.yudao.module.member.bonus.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.bonus.pojo.po.BonusUser;
import cn.iocoder.yudao.module.member.bonus.pojo.vo.BonusUserVO;
import cn.iocoder.yudao.module.member.bonus.service.app.AppBonusUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * 前端控制器
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/05/09
 */
@Tag(name = "用户 APP - 分红人员")
@RestController
@RequestMapping("/member/bonus/user")
public class AppBonusUserController {
    @Resource
    private AppBonusUserService appBonusUserService;

    @GetMapping("/my")
    @Operation(summary = "获得我的身份详情")
    @PreAuthorize("@mm.isBonus()")
    public CommonResult<BonusUserVO> getMyDetail() {
        BonusUser bonusUser = appBonusUserService.getOrCreate(getLoginUserId());
        BonusUserVO respVO = BeanUtils.toBean(bonusUser, BonusUserVO.class);
        return success(respVO);
    }

}
